package com.gd.deron.smartrobot.baobao.recevier;


import com.gd.deron.smartrobot.baobao.utils.Config;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class NetwordReceiver extends BroadcastReceiver {  
	
    @Override  
    public void onReceive(Context context, Intent intent) {  
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);  
       // NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);  
        NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);  
       // NetworkInfo activeInfo = manager.getActiveNetworkInfo();  
        Log.e("NetwordReceiver", "wifi:"+wifiInfo.isConnected());
        if(wifiInfo.isConnected())
        	sendBroad(Config.WIFICONNECT_SUCCESSFUL,context);
        else
        	sendBroad(Config.WIFICONNECT_FAILED,context);;
    }   
    
    private void sendBroad(String action,Context mContext){
    	Intent mIntent = new Intent();
    	mIntent.setAction(action);
    	mContext.sendBroadcast(mIntent);
    }
  
}